<?php
	//arrive a 31486
	drupal_set_title('');
	$url = $config->getVar('url');
	drupal_add_css('bdbdec/view/css/viewElement.css');
	drupal_add_css('bdbdec/view/css/jqueryRating.css');
	drupal_add_js('bdbdec/view/scripts/displayList.js');
	drupal_add_js('bdbdec/view/scripts/jqueryRating.js');
	drupal_add_js('misc/collapse.js');
		
		
	echo '
	<div id="tabs-wrapper" class="clear-block">
		<h2 class="with-tabs">'.$book->getName().'</h2>
	</div>
	<table>
		<thead>
			<tr>
				<th colspan="2">
					<a href="'.$url.'/bdbdec.php?action=displayList&amp;element=book">Retour &agrave; la liste des albums</a>
				</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class="cover">
					ICI image de la couverture !
				</td>
				<td class="informations">
					<table>
						<thead>
							<tr>
								<th colspan="4" class="center">Informations sur l\'album</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td class="title bold">Titre de l\'album :</td><td class="value">'.$book->getName().'</td>
								<td class="title bold">C&ocirc;te :</td><td class="value">'.$book->getCotation().'</td>
							</tr>
							<tr>
								<td class="title bold">Tome :</td><td class="value">'.$book->getTome().'</td>
								<td class="title bold">&Eacute;diteur :</td><td class="value"><a href="'.$url.'/bdbdec.php?action=viewElement&amp;element=publisher&amp;id='.$book->getIdpublisher().'">'.$book->getPublisher()->getName().'</a></td>
							</tr>
							<tr>
								<td class="title bold">Nom de la serie :</td><td class="value"><a href="'.$url.'/bdbdec.php?action=viewElement&amp;element=serie&amp;id='.$book->getIdserie().'">'.$book->getSerie()->getName().'</a></td>
								<td class="title bold">Emplacement :</td><td class="value">';
								if ($book->getLocation()=='butc') echo 'BUTC';
								else if ($book->getLocation()=='cave') echo '&Agrave; la cave';
								else if ($book->getLocation()=='sortie') echo 'Sortie';
								else if ($book->getLocation()=='couvrage') echo 'En couvrage';
								else if ($book->getLocation()=='remplacement') echo 'En remplacement';
								else if ($book->getLocation()=='reparation') echo 'En r&eacute;paration';
								else  echo 'Inconnu';
								echo '</td>
							</tr>
							<tr>
								<td class="title bold">Genre :</td><td class="value">'.$book->getSerie()->getGenre().'</td>
								<td class="title bold">EAN13/ISBN :</td><td class="value">'.$book->getEan13().'</td>
							</tr>
							<tr>
								<td class="title bold">Dep&ocirc;t l&eacute;gal :</td><td class="value">'.$book->getYear().'</td>
								<td class="title bold">Date de parution :</td><td class="value">'.$book->getParution().'</td>
							</tr>
							<tr>
								<td class="title bold">Note de la BD</td><td class="value" colspan="3">';
								$note = round($book->getRating());
								for ($r = 1; $r < 11; $r++)
								{
									$checked = '';
									if ($r == $note)
										$checked = 'checked="checked"';
									echo '<input name="rating_disabled" type="radio" value="'.$r.'" class="star" disabled="disabled" '.$checked.'/>';
								}
								echo '&nbsp;&nbsp;&nbsp;&nbsp;('.count($ratingList).' participation(s))';
								echo '
								</td>
							</tr>
							<tr>
								<td class="title bold">Auteur(s) :</td>
								<td colspan="3">';
								$count = count($book->getAuthorsList());
								foreach ($book->getAuthorsList() as $author)
								{
									echo '<a href="'.$url.'/bdbdec.php?action=viewElement&amp;element=author&amp;id='.$author->getId().'">'.$author->getName().' ('.$author->getType().')</a>';
									$i++;
									if ($i != $count)
										echo ', ';
								}
								
								echo '    
								</td>
							</tr>
							<tr>
								<td colspan="4"><b>Description :</b> '.$book->getDescription().'</td>
							</tr>
						</tbody>
					</table>
					
				</td>
			</tr>
			<tr>
				<td colspan="2" class="right">';
			if ($user->isAllowedTo(GRADE_MOD_BOOK))
				echo '<small><a href=""> Modifier cette BD</a></small>';
				
				echo '
				</td>
			</tr>';
	if ($user->isAllowedTo(GRADE_NOTE_BOOK))
	{
		if (isset($ratingList[$user->getId()]))
			echo '
			<tr><td colspan="2"><small>Vous avez d&eacute;j&agrave; vot&eacute; pour cette bande dessin&eacute;e</small></td></tr>';
		else
		{
			echo '
			<tr>
				<td colspan="2" class="notation">
					<form action="'.$url.'/bdbdec.php?action=rate" method="post">
						<fieldset class="collapsible collapsed">
							<legend><a href="#">D&eacute;posez votre avis !</a></legend>
							<p>
								Vous &eacute;tes oblig&eacute; d\'&eacute;crire un commentaire (m&ecirc;me petit) pour valider votre note : <br />';
								for ($k = 1; $k < 11; $k++)
									echo '<input name="rating" type="radio" value="'.$k.'" class="star"/>';
								echo '
								<br />
								<textarea name="commentary" style="width:95%;height:100px;">'."$commentary".'</textarea>
								<input type="hidden" name="element" value="book">
								<input type="hidden" name="id" value="'.$id.'">
								<input type="submit" value="Envoyez votre commentaire et votre vote">
							</p>
						</fieldset>
					</form>
				</td>
			</tr>';
		}
	}
		$z = 0;
		foreach ($ratingList as $rate)
		{
			if (isPair($z))
				$class = 'odd';
			else
				$class = 'even';
				
			echo '
			<tr class="'.$class.'">
				<td>'.$rate['us_lastname'].' '.$rate['us_firstname'].'</td>
				<td>';
				$note = $rate['no_note'];                            
				for ($q = 1; $q < 11; $q++)
				{
					$checked = '';
					if ($q == $note)
						$checked = 'checked="checked"';
					echo '<input name="rating_disabled_'.$rate['no_idUser'].'" type="radio" value="'.$q.'" class="star" disabled="disabled" '.$checked.'/>';
				}
				echo '<br />'.$rate['no_commentary'];
				if ($user->isAllowedTo(GRADE_MODERATE_COMMENTARY))
					echo '<div class="right"><small><a href="'.$url.'/bdbdec.php?action=moderateRating&amp;element=book&amp;id='.$book->getId().'&amp;no_id='.$rate['no_id'].'">Supprimer ce commentaire</a></small></div>';
				echo '</td>
			</tr>';
			
			$z++;
		}
			echo '
		</tbody>
		<tfoot>
			<tr>
			
			</tr>
		</tfoot>
	</table>';
	
?>